#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.


def parse_hex_color(s):
    r = int(s[1:3], 16)
    g = int(s[3:5], 16)
    b = int(s[5:7], 16)
    return (r, g, b)


# copied from https://stackoverflow.com/questions/2328339/how-to-generate-n-different-colors-for-any-natural-number-n
PALETTE_128 = list(map(
    parse_hex_color,
    ["#000000", "#FFFF00", "#1CE6FF", "#FF34FF", "#FF4A46", "#008941", "#006FA6", "#A30059",
     "#FFDBE5", "#7A4900", "#0000A6", "#63FFAC", "#B79762", "#004D43", "#8FB0FF", "#997D87",
     "#5A0007", "#809693", "#FEFFE6", "#1B4400", "#4FC601", "#3B5DFF", "#4A3B53", "#FF2F80",
     "#61615A", "#BA0900", "#6B7900", "#00C2A0", "#FFAA92", "#FF90C9", "#B903AA", "#D16100",
     "#DDEFFF", "#000035", "#7B4F4B", "#A1C299", "#300018", "#0AA6D8", "#013349", "#00846F",
     "#372101", "#FFB500", "#C2FFED", "#A079BF", "#CC0744", "#C0B9B2", "#C2FF99", "#001E09",
     "#00489C", "#6F0062", "#0CBD66", "#EEC3FF", "#456D75", "#B77B68", "#7A87A1", "#788D66",
     "#885578", "#FAD09F", "#FF8A9A", "#D157A0", "#BEC459", "#456648", "#0086ED", "#886F4C",
     "#34362D", "#B4A8BD", "#00A6AA", "#452C2C", "#636375", "#A3C8C9", "#FF913F", "#938A81",
     "#575329", "#00FECF", "#B05B6F", "#8CD0FF", "#3B9700", "#04F757", "#C8A1A1", "#1E6E00",
     "#7900D7", "#A77500", "#6367A9", "#A05837", "#6B002C", "#772600", "#D790FF", "#9B9700",
     "#549E79", "#FFF69F", "#201625", "#72418F", "#BC23FF", "#99ADC0", "#3A2465", "#922329",
     "#5B4534", "#FDE8DC", "#404E55", "#0089A3", "#CB7E98", "#A4E804", "#324E72", "#6A3A4C",
     "#83AB58", "#001C1E", "#D1F7CE", "#004B28", "#C8D0F6", "#A3A489", "#806C66", "#222800",
     "#BF5650", "#E83000", "#66796D", "#DA007C", "#FF1A59", "#8ADBB4", "#1E0200", "#5B4E51",
     "#C895C5", "#320033", "#FF6832", "#66E1D3", "#CFCDAC", "#D0AC94",
     "#7ED379", "#012C58"]))

PALETTE_256 = [(148, 172, 208), (129, 138, 147), (99, 85, 137), (113, 101, 124), (52, 35, 64), (104, 123, 183), (72, 102, 69), (0, 71, 190), (73, 51, 1), (1, 198, 79), (172, 205, 207), (95, 82, 2), (133, 140, 168), (117, 99, 99), (131, 129, 184), (120, 85, 136), (255, 144, 215), (171, 243, 163), (55, 88, 160), (77, 58, 148), (247, 163, 10), (208, 182, 221), (90, 0, 198), (76, 111, 136), (124, 0, 218), (0, 48, 232), (161, 175, 120), (59, 129, 85), (255, 35, 188), (75, 79, 123), (41, 35, 146), (159, 138, 149), (124, 96, 41), (211, 225, 102), (89, 26, 255), (60, 17, 91), (133, 164, 131), (255, 208, 140), (121, 158, 84), (186, 128, 109), (51, 0, 50), (53, 170, 204), (90, 75, 73), (63, 145, 255), (39, 49, 100), (53, 0, 0), (87, 247, 4), (255, 225, 245), (229, 177, 188), (44, 0, 107), (29, 32, 41), (1, 33, 55), (159, 208, 250), (220, 232, 253), (105, 132, 163), (102, 139, 234), (196, 4, 231), (30, 28, 0), (0, 110, 30), (52, 69, 91), (37, 22, 32), (197, 149, 150), (88, 160, 81), (47, 145, 118), (45, 54, 52), (158, 151, 151), (88, 208, 152), (1, 96, 76), (117, 43, 150), (6, 20, 57), (194, 191, 215), (39, 0, 226), (200, 198, 0), (255, 230, 28), (123, 84, 100), (153, 220, 198), (98, 0, 111), (201, 200, 163), (104, 120, 121), (137, 164, 163), (156, 72, 0), (96, 129, 75), (255, 52, 255), (80, 86, 191), (44, 44, 69), (50, 104, 255), (64, 98, 200), (160, 87, 209), (102, 106, 0), (0, 40, 34), (126, 142, 134), (0, 73, 122), (0, 38, 119), (213, 220, 210), (88, 171, 131), (138, 160, 21), (163, 137, 0), (233, 101, 188), (2, 23, 29), (65, 137, 0), (153, 194, 161), (7, 0, 90), (192, 173, 153), (229, 219, 255), (119, 225, 27), (90, 97, 97), (110, 62, 60), (255, 244, 181), (109, 121, 102), (40, 75, 0), (124, 184, 204), (170, 3, 185), (150, 0, 210), (167, 93, 255), (170, 148, 107), (89, 196, 190), (144, 17, 103), (135, 125, 153), (153, 115, 169), (255, 176, 143), (191, 121, 160), (0, 97, 209), (242, 160, 255), (68, 79, 61), (205, 96, 0), (201, 158, 120), (246, 208, 200), (67, 77, 0), (189, 168, 180), (111, 132, 0), (102, 105, 156), (0, 151, 155), (83, 59, 74), (195, 214, 181), (161, 161, 200), (170, 166, 0), (128, 47, 255), (68, 90, 125), (66, 111, 167), (102, 108, 128), (166, 148, 184), (41, 83, 87), (4, 232, 164), (252, 255, 228), (111, 91, 176), (160, 194, 0), (19, 50, 91), (73, 215, 244), (10, 0, 59), (206, 247, 209), (140, 187, 113), (3, 255, 94), (102, 189, 12), (172, 255, 99), (209, 188, 94), (24, 0, 48), (166, 111, 0), (78, 104, 2), (169, 103, 99), (2, 91, 164), (99, 171, 231), (37, 19, 0), (230, 255, 254), (0, 9, 186), (101, 36, 58), (147, 115, 131), (39, 69, 55), (254, 255, 255), (1, 58, 81), (98, 151, 183), (178, 185, 192), (100, 58, 107), (210, 201, 189), (153, 255, 194), (146, 170, 255), (118, 129, 233), (210, 69, 0), (143, 65, 114), (170, 171, 244), (100, 160, 159), (147, 150, 128), (255, 239, 221), (0, 117, 167), (0, 255, 255), (93, 103, 71), (0, 2, 30), (0, 151, 59), (88, 44, 1), (78, 131, 202), (159, 246, 255), (95, 0, 0), (138, 115, 89), (240, 148, 159), (102, 61, 216), (0, 63, 58), (207, 254, 0), (121, 211, 126), (85, 78, 64), (120, 106, 216), (49, 108, 0), (255, 195, 238), (255, 123, 122), (255, 93, 59), (89, 0, 163), (9, 49, 0), (237, 255, 194), (51, 180, 0), (221, 213, 219), (0, 180, 139), (135, 138, 81), (191, 201, 247), (0, 63, 149), (57, 51, 53), (42, 58, 26), (189, 86, 149), (0, 121, 107), (1, 142, 214), (35, 60, 69), (113, 251, 223), (70, 133, 141), (125, 143, 108), (201, 144, 255), (154, 138, 255), (180, 219, 138), (145, 216, 0), (198, 178, 254), (0, 68, 27), (0, 0, 0), (68, 7, 204), (215, 0, 121), (117, 109, 69), (0, 181, 255), (5, 100, 126), (161, 135, 122), (164, 178, 159), (113, 69, 167), (152, 126, 203), (136, 129, 101), (190, 137, 62), (3, 18, 6), (197, 149, 200), (206, 115, 231), (102, 141, 120), (124, 121, 117), (237, 134, 0), (216, 166, 10), (76, 58, 106), (114, 78, 50), (81, 78, 91), (46, 65, 137), (166, 0, 0), (70, 74, 255), (9, 30, 0), (74, 113, 106), (60, 59, 32), (153, 81, 170)]
PALETTE_256 = [x[::-1] for x in PALETTE_256]
